package dao;

import models.Photo;

import java.util.*;

/**
 * Created by VLAD on 19.08.2014.
 */
public class PhotoDao implements IPhotoDao {
    private Map<Integer, Photo> recourses = new HashMap();

    @Override
    public void addPhoto(Photo photo) {
        recourses.put(photo.getId(), photo);
    }

    @Override
    public List getAllPhotos() {
        List<Photo> toReturn = new LinkedList<Photo>();

        Iterator<Photo> iter = recourses.values().iterator();
        while (iter.hasNext())
        {
            toReturn.add(iter.next());
        }

        return toReturn;
    }

    @Override
    public void delPhoto(Photo photo) {
        recourses.remove(photo.getId());

    }

    @Override
    public int getSize() {
        return recourses.size();
    }
}
